package storage

import (
	"testing"

	"github.com/minio/minio-go"
	. "github.com/smartystreets/goconvey/convey"
)

func TestConvertStorageParameterToOptions(t *testing.T) {
	Convey("test minio Paremeter convert", t, func() {
		opt := minio.PutObjectOptions{}
		paramWrong := []StorageParemeter{map[string]string{"a": "b"}}
		paramEmpty := []StorageParemeter{}
		So(convertStorageParemterToPutObjectOptions(nil, &opt), ShouldBeNil)
		So(convertStorageParemterToPutObjectOptions(paramWrong, &opt), ShouldNotBeNil)
		So(convertStorageParemterToPutObjectOptions(paramEmpty, &opt), ShouldBeNil)

		paramright := []StorageParemeter{map[string]string{"ContentType": "123"}}
		So(convertStorageParemterToPutObjectOptions(paramright, &opt), ShouldBeNil)
		So(opt.ContentType, ShouldEqual, "123")

		optg := minio.GetObjectOptions{}
		So(convertStorageParemterToGetObjectsOptions(paramEmpty, &optg), ShouldBeNil)
		So(convertStorageParemterToGetObjectsOptions(nil, &optg), ShouldBeNil)
		So(convertStorageParemterToGetObjectsOptions(paramright, &optg), ShouldNotBeNil)

	})

}
